<?php

namespace app\admin\model;

use app\common\model\Base;

class Room extends Base {
  protected $name = 'room';
  protected $updateTime = FALSE;

  public function initialize() {
    parent::initialize();
  }

  public function getStatusTextAttr($value, $data) {
    $text = ['未开始',
             '已开始',
             '已结束'];

    return $text[ $data['status'] ];
  }

  /**
   * 未曾开始的班级
   */
  public function startedClass() {
    return self::alias('r')
      ->join('__CLASS__ c', 'c.id=r.class_id', 'left')
      ->where('r.status', 1)
      ->field('r.*,c.title')->find();
  }


}